﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using SqlCon;

namespace yfxt
{
    public partial class zy_fy_rpt : Form
    {
        public zy_fy_rpt()
        {
            InitializeComponent();
        }
        zy_fy_DataSet ds = new zy_fy_DataSet();
        int tjxh;
        string sql_fyd;
        static string SQL = "data source=localhost;database=yf;uid=sa;pwd=123;timeout=60";
        private void zy_fy_rpt_Load(object sender, EventArgs e)
        {
            zy_ptyz zyfy=(zy_ptyz)this.Owner;
            if (zy_ptyz.int_ptyz == 2) tjxh = zy_ptyz.tjxh;
            if (zy_jzyy.int_jzzy == 2) tjxh = zy_jzyy.tjxh;
            if (zy_cydy.int_cydy == 2) tjxh = zy_cydy.tjxh;

            //SqlParameter[] para = new SqlParameter[] 
            //{
            //    new SqlParameter("@tjxh",tjxh)
            //};
            sql_fyd = "select b.brch,b.brxm,c.ypmc,a.fysl,a.sypc,a.yfgg,a.yfdw,a.ypdj,(a.fysl*a.ypdj) as zjje " +
                "from bq_tj02 a," +
                "zy_brry b," +
                "yk_typk c " +
                "where a.tjxh='" + tjxh + "' " +
                "and a.fybz=0 " +
                "and a.lsyz=0 " +
                "and a.zyh=b.zyh " +
                "and a.ypxh=c.ypxh ";
               
            SqlConnection con = new SqlConnection(SQL);

            
            SqlDataAdapter da = new SqlDataAdapter(sql_fyd,con);

            da.Fill(ds.Tables["dt_fyd"]);


           zy_fy_crpt crpt = new zy_fy_crpt();
            crpt.SetDataSource(ds);
            crystalReportViewer1.ReportSource = crpt;
        }
    }
}
